#include "pch.h"
#include "Engine.h"

namespace TryEngine
{
    Engine::Engine()
    :m_Run(true),m_Window(nullptr),m_Width(SCREEB_WIDTH),m_Height(SCREEN_HEIGHT)
    {
        glfwInit();
        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
        glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

        auto& monitor = *glfwGetVideoMode(glfwGetPrimaryMonitor());

        glfwWindowHint(GLFW_RED_BITS, monitor.redBits);
        glfwWindowHint(GLFW_GREEN_BITS, monitor.greenBits);
        glfwWindowHint(GLFW_BLUE_BITS, monitor.blueBits);
        glfwWindowHint(GLFW_REFRESH_RATE, monitor.refreshRate);

        m_Window = glfwCreateWindow(m_Width, m_Height, "TryEngine", nullptr, nullptr);
        assert(m_Window && "Failed to create window");
        glfwMakeContextCurrent(m_Window);

        assert(glewInit() == GLEW_OK && "Failed to initialize GLEW");
        glewExperimental = GL_TRUE;
    }

    Engine::~Engine()
    {
        glfwTerminate();
    }

    void Engine::Initialize()
    {
        //TODO: Initialize engine
    }

    void Engine::Update()
    {
        //TODO: Update engine
    }

    void Engine::Quit()
    {
        glfwSetWindowShouldClose(m_Window, GLFW_TRUE);
        m_Run = false;
    }
}